<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
		<!-- 引入样式 -->
		<link rel="stylesheet" href="../../plugins/element-ui/index.css" />
		<link rel="stylesheet" href="../../styles/common.css" />
		<link rel="stylesheet" href="../../styles/page.css" />
		<style>
			#member-app .notAdmin::after {
				border: 0 !important;

			}
		</style>
	</head>
	<body>
		<div class="dashboard-container" id="member-app">
			<div class="container">
				
				<el-form :inline="true" :model="form" class="demo-form-inline">
					<el-form-item label="航班号">
						<el-input v-model="form.id" placeholder="请输入变更航班号"></el-input>
					</el-form-item>
					

					<el-form-item>
						<el-button type="primary" @click="onSubmit">确定</el-button>
					</el-form-item>
				</el-form>
				
				<el-table :data="tableData" stripe class="tableBox">
					<el-table-column prop="cfno" label="航班号"></el-table-column>
					<el-table-column prop="star" label="起始站"></el-table-column>
					<el-table-column prop="ends" label="终点站"></el-table-column>
					<el-table-column prop="tables" label="值班柜台"></el-table-column>
					<el-table-column prop="startime" align="center" label="起飞时间" width="180px"></el-table-column>
					<el-table-column prop="endtime" align="center" label="到达时间" width="180px"></el-table-column>
					<el-table-column align="center" label="航班状态">
						<template slot-scope="scope">
							{{ String(scope.row.status) === '0' ? '运行异常' : '运行正常' }}
						</template>
					</el-table-column>
					 <el-table-column label="操作">
					      <template slot-scope="scope">
					        
					        <el-button
					          size="mini"
					          type="danger"
					          @click="apply(scope.$index, scope.row)">变更申请</el-button>
					      </template>
					    </el-table-column>
				</el-table>
				<el-pagination class="pageList" :page-sizes="[5,10,15,20]" :page-size="pageSize"
					layout="total, sizes, prev, pager, next, jumper" :total="counts" :current-page.sync="page"
					@size-change="handleSizeChange" @current-change="handleCurrentChange"></el-pagination>
			</div>
		</div>
		<!-- 开发环境版本，包含了有帮助的命令行警告 -->
		<script src="../../plugins/vue/vue.js"></script>
		<!-- 引入组件库 -->
		<script src="../../plugins/element-ui/index.js"></script>
		<!-- 引入axios -->
		<script src="../../plugins/axios/axios.min.js"></script>
		<script src="../../js/request.js"></script>
		<script src="../../api/member.js"></script>
		<script>
			new Vue({
				el: '#member-app',
				data() {
					return {
						user: '',
						input: '',
						counts: 0,
						page: 1,
						pageSize: 5,
						tableData: [],
						id: '',
						status: '',
						form: {
							id: '',
							startStation: '',
							endStation: '',
							startTime: '',
							endTime: '',
							status: ''
						}
						
					}
				},
				computed: {},
				created() {
					
					
					if (sessionStorage.getItem('userInfo') != null) {
						//获取当前登录员工的账号，并赋值给模型数据user
						var userInfo = sessionStorage.getItem("userInfo");
						 userInfo=JSON.parse(userInfo)
						this.user=userInfo[0].username;
						
						
					}
				},
				mounted() {},
				methods: {
					async init() {
						const params = {
							page: this.page,
							pageSize: this.pageSize,
							input: JSON.stringify(this.form)
						}
						await getFlightList(params).then(res => {
							console.log(res)
							if (String(res.code) === '200') {
								for (var i = 0; i < res.data.data.length; i++) {
									var timeString = res.data.data[i].startime;
									var year = timeString.substring(0, 4);
									var month = timeString.substring(4, 6);
									var day = timeString.substring(6, 8);
									var hour = timeString.substring(8, 10);
									var minute = timeString.substring(10, 12);
									var second = timeString.substring(12, 14);

									var formatStartTime = year + "-" + month + "-" + day + " " + hour + ":" +
										minute +
										":" + second;
									res.data.data[i].startime = formatStartTime

									var timeString = res.data.data[i].endtime;
									var year = timeString.substring(0, 4);
									var month = timeString.substring(4, 6);
									var day = timeString.substring(6, 8);
									var hour = timeString.substring(8, 10);
									var minute = timeString.substring(10, 12);
									var second = timeString.substring(12, 14);

									var formatEndTime = year + "-" + month + "-" + day + " " + hour + ":" +
										minute +
										":" + second;
									res.data.data[i].endtime = formatEndTime
								}

								console.log(res)
								this.tableData = res.data.data || []
								this.counts = res.data.total
								
							}
						}).catch(err => {
							this.$message.error('请求出错了：' + err)
						})
					},
					
					handleQuery() {
						this.page = 1;
						this.init();
					},
					apply(index, row) {
					    console.log(index, row);
						sessionStorage.setItem("apply",JSON.stringify(row))
						window.parent.menuHandle({
						 			id: '2',
									url: 'page/member/add.html?data=' + row,
						 			name: '航班变更申请'
								}, true)
						
					},
					
					handleSizeChange(val) {
						this.pageSize = val
						this.init()
					},
					onSubmit() {
					
						
						this.form.status='1';
						console.log(this.form);
						this.init();
					},
					handleCurrentChange(val) {
						this.page = val
						this.init()
					}
				}
			})
		</script>
	</body>
</html>
